home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_02_01
/
2n01008b
< prev
next >
Wrap
Text File
|
1990-12-02
|
922b
|
55 lines
/* threads2.c */
/* Listing 2 -- An example of an alarm thread, with higher priority */
#include <conio.h>
#include <process.h>
#define INCL_DOSPROCESS
#include <os2.h>
USHORT beeperThreadID;
#define BEEPER_SSIZE 3000
void beeper( void *arg);
int Horn = 0;
void main(void)
{
char c;
beeperThreadID = _beginthread( beeper, NULL,
BEEPER_SSIZE, NULL);
while (c= (char) getch() )
{
if (c == 'a')
Horn = 1;
else if (c == 'c')
Horn = 0;
else if (c == 'x')
break;
}
}
/* "arg" here is a dummy --
just to satify the compiler */
void beeper( void *arg)
{
DosSetPrty( PRTYS_THREAD,
PRTYC_TIMECRITICAL,
PRTYD_MINIMUM, 0);
while (1)
{
if (Horn)
{
DosBeep( 1000, 125);
DosBeep( 750, 125);
}
else
{
DosSleep( 250L);
}
}
}